/*
 * Route.cpp
 *
 *  Created on: Mar 13, 2011
 *      Author: kmueller
 */

#ifndef ROUTE_H_
#define ROUTE_H_

#include "Map.h"
#include "Geo.h"
#include "Road.h"

#include <vector>

namespace opennav {

enum TravelTimeUnit {
	SECONDS, MINUTES, HOURS
};

class RouteSegment {
public:
	enum RouteInstruction {
		CONTINUE_STRAIGHT, TURN_RIGHT, TURN_LEFT
	};

	RouteSegment(const RoadJunction& from, const RoadSegment& via,
			const RoadJunction& to);

	const RouteInstruction instruction() const;
	int32_t length() const;
	int32_t travel_time(const TravelTimeUnit unit) const;

	const RoadJunction& start_junction() const;
	const RoadJunction& end_junction() const;
	const RoadSegment& road_segment() const;
	//	const std::vector<Coordinate>& geometry() const;
	//	const Box& bounds() const;

	bool operator==(const RouteSegment& c) const	{
		return src.coordinate == c.start_junction().coordinate
				&& dst.coordinate == c.end_junction().coordinate;
	}

private:
	RoadJunction src, dst;
	RoadSegment segment;
};

class Route {
public:
	Route();
	void add_segment(RouteSegment& segment);
	const Coordinate& destination() const;
	const Coordinate& start() const;
	int32_t length() const;
	int32_t length(const RoadSegment* segment) const;
	int32_t travel_time(const TravelTimeUnit unit) const;
	int32_t travel_time(const RoadSegment* segment, const TravelTimeUnit unit) const;
	const std::vector<RouteSegment>& segments() const;
	//	const std::vector<Coordinate>& geometry() const;
	//	const Box& bounds() const;

private:
	int32_t length_;
	std::vector<RouteSegment> segments_;
};

}

#endif
